<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../layuimini-2/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuimini-2/css/layuimini.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label 房间号">房间号</label>
        <div class="layui-input-block">
            <input type="text" name="roomNum" lay-verify="required" lay-reqtext="房间号不能为空" placeholder="请输入房间号" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">物品类型</label>
        <div class="layui-input-block">
            <input type="text" name="goodsType" lay-verify="required" lay-reqtext="物品类型不能为空" placeholder="请输入房间类型" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">物品价格</label>
        <div class="layui-input-block">
            <input type="text" name="price" lay-verify="required" lay-reqtext="物品价格不能为空" placeholder="请输入楼层" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">物品数量</label>
        <div class="layui-input-block">
            <input type="text" name="num" lay-verify="required" lay-reqtext="物品数量不能为空" placeholder="请输入面积" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="../../../layuimini-2/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    var form;
    var layer;
    var jquery;
    layui.use(['form',"layer","jquery","laydate"], function () {
        form = layui.form,
        layer = layui.layer,
        $ = layui.jquery,
        laydate= layui.laydate,

        //监听提交
        form.on('submit(saveBtn)', function (obj) {

            $.ajax({
                url:"/goods/add.do",
                type:"POST",
                data:obj.field,
                success:function (ret) {
                    // console.log("ret ==>",ret.code);
                    if (ret.code == 0) {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    } else {
                        layer.msg("添加失败!")
                    }
                },
                error:function (){
                    layer.msg("服务器正忙!")
                }
            })
            return false;
        });
    });
</script>
</body>
</html>